import React, { useState } from 'react';

export default function UseState () {
    const [count, setCount] = useState({ value: 0 });
    return (
        <div>
            {count.value}
            <br/>
            方法一:
            <button onClick={() => setCount({ value: count.value + 1 })}>+</button>
            <br/>
            方法二:
            <button onClick={() => setCount((preVal) => ({ value: preVal.value + 1 }))}>+</button>
        </div>
    );
}
